//
//  CourseCell.m
//  TrainTree
//
//  Created by wanghui on 2017/9/12.
//  Copyright © 2017年 YouYeShu. All rights reserved.
//

#import "CourseCell.h"
@implementation CourseCell

- (void)awakeFromNib {
    [super awakeFromNib];
 
    self.progress = [[M13ProgressViewBorderedBar alloc]initWithFrame:CGRectMake(0, 0, 0, 8)];
    [self.progressView addSubview:self.progress];
    [self.progress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.equalTo(@0);
        make.bottom.equalTo(@0);
        make.right.equalTo(@0);
    }];
    self.progress.cornerType = M13ProgressViewBorderedBarCornerTypeCircle;

    self.progress.primaryColor = rgb(131, 38, 118);
    self.progress.backgroundColor = rgb(231, 231, 231);
    [self.progress setProgress:6.0f / 13.0f animated:NO];

    self.progress.layer.cornerRadius = 4.0f;
    self.progress.layer.masksToBounds = YES;
    self.progress.borderWidth = 0;

    self.progressView.layer.cornerRadius = 4.0f;
    self.progressView.layer.masksToBounds = YES;

    self.iconBtn.layer.cornerRadius = 18.0f;
}

- (void)adjustProgressWithData:(StudyCourseModel *)model withType:(StudyType)type
{
    PageType tmp = [model.themeId integerValue];

    if (tmp == PageTypeUniverse) {
        self.progress.primaryColor = universeColor;
        self.iconBtn.backgroundColor = universeColor;
        [self.iconBtn setImage:ImageNamed(@"universe_select") forState:UIControlStateNormal];
    } else if (tmp == PageTypeLeader){
        self.progress.primaryColor = leaderColor;
        self.iconBtn.backgroundColor = leaderColor;
        [self.iconBtn setImage:ImageNamed(@"leadership_select") forState:UIControlStateNormal];
    } else if (tmp == PageTypeOperation){
        self.progress.primaryColor = operationColor;
        self.iconBtn.backgroundColor = operationColor;
        [self.iconBtn setImage:ImageNamed(@"operation_select") forState:UIControlStateNormal];
    } else if (tmp == PageTypeHr){
        self.progress.primaryColor = hrColor;
        self.iconBtn.backgroundColor = hrColor;
        [self.iconBtn setImage:ImageNamed(@"hr_select") forState:UIControlStateNormal];
    } else if (tmp == PageTypeFinance){
        self.progress.primaryColor = financeColor;
        self.iconBtn.backgroundColor = financeColor;
        [self.iconBtn setImage:ImageNamed(@"finance_select") forState:UIControlStateNormal];
//    } else if (tmp == PageTypeLec){
    } else {
        self.progress.primaryColor = lecColor;
        self.iconBtn.backgroundColor = lecColor;
        [self.iconBtn setImage:ImageNamed(@"lec_select") forState:UIControlStateNormal];
    }
    if (type == StudyTypeRequired) {
        self.schedule.text = [NSString stringWithFormat:@"完成%@/%@ 剩余%@天",model.studyProgress,model.studyCount,model.overDays];
    }else{
        self.schedule.text = [NSString stringWithFormat:@"完成%@/%@",model.studyProgress,model.studyCount];
    }

    self.typeName.text = model.moduleName;
    self.subTypeName.text =[NSString stringWithFormat:@" / %@",model.lessonName];

    [self.progress setProgress:[model.studyProgress floatValue] / [model.studyCount floatValue] animated:NO];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
